package com.changgou.mq.queue;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @author ：hushengjin
 */

@Configuration
public class TopicQueue {

    private static final String TOPIC_QUEUE_SPU = "topic_queue_spu";
    private static final String TOPIC_EXCHANGE_SPU = "topic_exchange_spu";

    /**
     * Topic模式 SPU变更队列
     *
     * @return
     */
    @Bean
    public Queue topicSpuQueue() {
        return new Queue(TOPIC_QUEUE_SPU);
    }

    /**
     * SPU队列交换机
     *
     * @return
     */
    @Bean
    public Exchange topicSpuExchange() {
        return new TopicExchange(TOPIC_EXCHANGE_SPU);
    }

    /**
     * 队列绑定交换机
     *
     * @param topicSpuQueue
     * @param topicSpuExchange
     * @return
     */
    @Bean
    public Binding topicBinding1(Queue topicSpuQueue, Exchange topicSpuExchange) {
        return BindingBuilder.bind(topicSpuQueue).to(topicSpuExchange).with(TOPIC_QUEUE_SPU).noargs();
    }

}
